import QtQuick 2.15
import QtQuick.Controls 2.15

ApplicationWindow {
    height: 200
    title: "Event Handling Example"
    visible: true
    width: 400

    Text {
        id: label

        property int spacePress: 0

        font.pixelSize: 16
        text: 'Space pressed: ' + spacePress + ' times'
        x: 24
        y: 24

        focus: true
        Keys.onSpacePressed: {
            label.spacePress++;
            console.log("Space pressed:", label.spacePress, "times");
        }
        Keys.onEscapePressed:{
            label.text = ''
            console.log("label.text bind space Pressed cancel");
        }
    }
    MouseArea {
        anchors.fill: parent

        onClicked: {
            label.spacePress++;
            console.log("Space pressed:", label.spacePress, "times");
        }
    }
}
